<?php

namespace app\index\controller;

class SalesmanBase
{
    public function detail()
    {
        $query = \app\model\Salesman::field(['id', 'phone', 'real_name', 'invoice_tax', 'company_id'])->with(['company']);

        if ($phone = input('phone')) {
            $query->where('phone', $phone);
        }

        if ($token = input('token')) {
            $query->where('token', $token);
        }

        $model = $query->find();

        return json(['code' => 20000, 'data' => ['salesman' => $model]]);
    }
}
